from datetime import datetime
from decimal import Decimal


class ETF_MODEL:
    code: str   ## 代码
    name: str   ## 名称
    update_time: datetime  ## 更新时间
    valid_date: datetime  # Note: I changed this to datetime for easier handling in Python  ##数据日期
    net: float  ## 最新价
    netagg: float   ## IOPV实时估值
    fund_type: str   ## 基金类型
    status_type: str   ## 状态类型
    annually_rate: Decimal   ## 基金折价率
    amount: float  # Units in billions  ## 成交量（单位-亿）
    company: str   ## 公司
    manager: str   ## 经理

    def __init__(self):
        pass

    def to_dict(self) -> dict:
        # Convert ETF object to dictionary
        # Note: You may need to handle date/datetime conversions properly here
        return {
            'code': self.code,
            'name': self.name,
            'update_time': self.update_time.isoformat(),
            'valid_date': self.valid_date.isoformat(),  # Or use str(self.valid_date) for 'YYYY-MM-DD'
            'net': self.net,
            'netagg': self.netagg,
            # 'fund_type': self.fund_type,
            # 'status_type': self.status_type,
            # 'annually_rate': str(self.annually_rate),  # Decimal to string
            'amount': self.amount,
            # 'company': self.company,
            # 'manager': self.manager
        }